﻿using Beetle;
using System;
using System.Collections.Generic;

internal class Class_h : IDisposable
{
    protected Queue<Class_a> _field_a;
    private int _field_b;
    private bool _field_c;

    static Class_h()
    {
        Class_aa.f();
    }

    public Class_h(int A_0)
    {
        this._field_a = new Queue<Class_a>(A_0);
        for (int i = 0; i < A_0; i++)
        {
            this._field_a.Enqueue(this.c());
        }
    }

    public Class_h(int A_0, int A_1)
    {
        this._field_b = A_1;
        this._field_a = new Queue<Class_a>(A_0);
        for (int i = 0; i < A_0; i++)
        {
            this._field_a.Enqueue(this.c());
        }
    }

    private void a()
    {
        while (this._field_a.Count > 0)
        {
            this._field_a.Dequeue().a((Class_h) null);
        }
    }

    public virtual void a(Class_a A_0)
    {
        lock (this._field_a)
        {
            A_0.a((TcpChannel) null);
            this._field_a.Enqueue(A_0);
        }
    }

    public int b()
    {
        return this._field_a.Count;
    }

    protected Class_a c()
    {
        Class_a _a = null;
        if (this._field_b > 0)
        {
            _a = new Class_a(this._field_b);
        }
        else
        {
            _a = new Class_a();
        }
        _a.a(this);
        return _a;
    }

    public virtual Class_a d()
    {
        lock (this._field_a)
        {
            Class_a _a = null;
            if (this._field_a.Count > 0)
            {
                _a = this._field_a.Dequeue();
            }
            else
            {
                _a = this.c();
            }
            _a.c();
            return _a;
        }
    }

    public void Dispose()
    {
        lock (this)
        {
            if (!this._field_c)
            {
                this.a();
                this._field_c = true;
            }
        }
    }
}

